Clear a list of variables used for intermediate calculations.
Create two variables in the workspace.
cashOnHand = 20;cost = 12.99;Store a list of the names of all the variables currently in the workspace.
initialVars = who;Specify or calculate additional variables, taxRate and tax.
taxRate = 0.0625;tax = round(100*cost*taxRate)/100;Update the initial variables, cost and cashOnHand.
cost = cost + tax;cashOnHand = cashOnHand - cost;Clear all variables except the initial variables, using the function form of clearvars. When using the function form of a syntax, enclose input character vectors in single quotes, and separate them with commas.
clearvars('-except',initialVars{:})clearvars clears the variables, initialVars, taxRate, and tax.